﻿@model AddressBookDev.ViewModels.ContactViewModel

@{
    ViewBag.Title = "Contact";
}

<section class="contact">
    <div class="contact_edit">
        <div class="edit_img">
        @using (Html.BeginForm("PreviewImage", "Home", FormMethod.Post, new { id = "image_form", enctype = "multipart/form-data" }))
        {
            @Html.AntiForgeryToken()
            <img id="contact_image" src="@Url.Content(Model.Picture)" alt="@Model.Name"/>
            <div class="image_btn" id="image_button_background" >
                <a id="image_btn_label" class="image_button_label">Change picture</a>
                @Html.TextBoxFor(m => m.PictureFile, new {id = "image_upload", Class = "image_upload", type = "file", accept = "image/*"})
                @Html.ValidationMessageFor(m => m.PictureFile)
            </div>
        }
            <div class="contact_title">
                @ViewBag.Message
            </div>
        </div>
        @using (Html.BeginForm("SaveContact", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "contact_form" }))
        {
            @Html.AntiForgeryToken()
        
            <table>
                <tr>
                    <td>@Html.LabelFor(m => m.Name)</td>
                    <td>@Html.TextBoxFor(m => m.Name)</td>
                    <td>@Html.ValidationMessageFor(m => m.Name)</td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(m => m.Email)</td>
                    <td>@Html.TextBoxFor(m => m.Email)</td>
                    <td>@Html.ValidationMessageFor(m => m.Email)</td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(m => m.Phone)</td>
                    <td>@Html.TextBoxFor(m => m.Phone)</td>
                    <td>@Html.ValidationMessageFor(m => m.Phone)</td>
                </tr>
                <tr>
                    <td class="align_top">@Html.LabelFor(m => m.Address)</td>
                    <td>@Html.TextAreaFor(m => m.Address)</td>
                    <td>@Html.ValidationMessageFor(m => m.Address)</td>
                </tr>
            
            </table>
            
            
            @Html.HiddenFor(m => m.Id)
            @Html.HiddenFor(m => m.PicWidth)
            @Html.HiddenFor(m => m.PicHeight)
            @Html.HiddenFor(m => m.PicX)
            @Html.HiddenFor(m => m.PicY)
            @Html.HiddenFor(m => m.ServerPath)
            @Html.HiddenFor(m => m.Picture)
            <br/>
            <div>
                <input type="submit" value="Save" />
                <input type="button" value="Cancel" onclick="location.href='@Url.Action("Index", "Home")'"/>
            </div>
        }
    </div>
</section>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}